#include <stdio.h>
int main()
{
    unsigned int amt;
    scanf("%u", &amt);
    unsigned int allcpt[amt][4];
    unsigned int lx, ly;
    unsigned int x, y;
    unsigned int ans;
    for (int i = 0; i < amt; i++)
    {
        scanf("%u %u %u %u", allcpt[i], allcpt[i] + 1, &lx, &ly);

        allcpt[i][2] = allcpt[i][0] + lx;
        allcpt[i][3] = allcpt[i][1] + ly;
    }
    scanf("%u %u", &x, &y);
    for (int i = amt - 1; i >= 0; i--)
    {
        if ((allcpt[i][0] <= x) && (allcpt[i][2] >= x) && (allcpt[i][1] <= y) && (allcpt[i][3] >= y))
        {
            printf("%u", (i + 1));
            return 0;
        }
    }
    printf("%d", -1);
    /* for (int i = 0; i < amt; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            printf("%u ", allcpt[i][j]);
        }
        printf("\n");
    } */
}
